package org.sport.model.entityModel;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by Allen on 2017/9/29.
 */
@Entity
@Table(name = "userinfohistorytable", schema = "sportinfo", catalog = "")
public class UserinfohistorytableEntity {
    private Timestamp time;
    private Double weight;
    private Double bodyFatRate;
    private String otherData;
    private int id;
    private UsertableEntity usertableByUserId;

    @Basic
    @Column(name = "time", nullable = true)
    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    @Basic
    @Column(name = "weight", nullable = true, precision = 0)
    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }

    @Basic
    @Column(name = "bodyFatRate", nullable = true, precision = 0)
    public Double getBodyFatRate() {
        return bodyFatRate;
    }

    public void setBodyFatRate(Double bodyFatRate) {
        this.bodyFatRate = bodyFatRate;
    }

    @Basic
    @Column(name = "otherData", nullable = true, length = 45)
    public String getOtherData() {
        return otherData;
    }

    public void setOtherData(String otherData) {
        this.otherData = otherData;
    }

    @Id
    @Column(name = "_id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserinfohistorytableEntity that = (UserinfohistorytableEntity) o;

        if (id != that.id) return false;
        if (time != null ? !time.equals(that.time) : that.time != null) return false;
        if (weight != null ? !weight.equals(that.weight) : that.weight != null) return false;
        if (bodyFatRate != null ? !bodyFatRate.equals(that.bodyFatRate) : that.bodyFatRate != null) return false;
        if (otherData != null ? !otherData.equals(that.otherData) : that.otherData != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = time != null ? time.hashCode() : 0;
        result = 31 * result + (weight != null ? weight.hashCode() : 0);
        result = 31 * result + (bodyFatRate != null ? bodyFatRate.hashCode() : 0);
        result = 31 * result + (otherData != null ? otherData.hashCode() : 0);
        result = 31 * result + id;
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "userId", referencedColumnName = "_id")
    public UsertableEntity getUsertableByUserId() {
        return usertableByUserId;
    }

    public void setUsertableByUserId(UsertableEntity usertableByUserId) {
        this.usertableByUserId = usertableByUserId;
    }
}
